﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="gridReport.ascx.cs" Inherits="GUESTSMANAGEMENT.View.Report.gridReport" %>
<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>

<ext:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</ext:ScriptManagerProxy>
<script type="text/javascript">
    var submitValue = function(grid, hiddenFormat, format) {
        hiddenFormat.setValue(format);
        grid.submitData(false);
    }

    var template = '<span style="color:{0};">{1}</span>';

    var change = function(value) {
        return String.format(template, (value > 0) ? 'green' : 'red', value);
    }

    var pctChange = function(value) {
        return String.format(template, (value > 0) ? 'green' : 'red', value + '%');
    }
</script>

<ext:DesktopWindow ID="winGrdReport" AutoHeight="true" Maximizable="false" ExpandOnShow="false" runat="server" Collapsible="true" Icon="User" Title="Relatório" Width="600" Height="400">
    <Body>
        <ext:Store ID="reportStore" 
            runat="server" 
            RefreshAfterSaving="Auto"
            OnSubmitData="Store1_Submit"
            AutoLoad="true" 
            RemoteSort="true">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="NMUSER" />
                        <ext:RecordField Name="NMEVENT" />
                        <ext:RecordField Name="CONFIRMADOS" />
                        <ext:RecordField Name="BNFEM" />
                        <ext:RecordField Name="BNMASC" />
                        <ext:RecordField Name="FRFEM" />
                        <ext:RecordField Name="FRMASC" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store> 
               
       <ext:Panel ID="Panel1" runat="server" Width="590" Height="470">
            <Body>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <North>
                        <ext:FormPanel Width="600" Height="60" ID="FormPanel2" runat="server" Title="Dados do Evento" BodyStyle="padding:5px;" ButtonAlign="Right">
                            <Body>
                                <ext:ColumnLayout ID="ColumnLayout1" runat="server">
                                    <ext:LayoutColumn ColumnWidth=".4">
                                        <ext:Panel ID="LayoutColumn1" runat="server" Border="false">
                                            <Body>
                                                <ext:FormLayout ID="FormLayout2" runat="server">
                                                    <ext:Anchor>
                                                        <ext:DateField ID="eventDate" FieldLabel="Data" runat="server" AllowBlank="false" Width="100" BlankText="Data é requerido!" >
                                                            <AjaxEvents>
                                                                <Select OnEvent="EnventDateSelected" />
                                                            </AjaxEvents>
                                                        </ext:DateField>
                                                    </ext:Anchor>    
                                                </ext:FormLayout>
                                            </Body>
                                        </ext:Panel>
                                    </ext:LayoutColumn>
                                    <ext:LayoutColumn ColumnWidth=".6">
                                        <ext:Panel ID="LayoutColumn2" runat="server" Border="false">
                                            <Body>
                                                <ext:FormLayout ID="FormLayout3" runat="server">
                                                    <ext:Anchor>
                                                        <ext:TextField Width="200" ID="eventName" ReadOnly="true" FieldLabel="Evento" runat="server" MaxLength="255" />
                                                    </ext:Anchor>
                                                </ext:FormLayout>
                                            </Body>
                                        </ext:Panel>
                                    </ext:LayoutColumn>
                                </ext:ColumnLayout>
                            </Body>
                        </ext:FormPanel>
                    </North>
                    <Center>
                        <ext:GridPanel ID="reportGridPanel" 
                            runat="server"
                            OnSubmitData="Store1_Submit"
                            StoreID="reportStore"
                            StripeRows="true"
                            AutoWidth="true"
                            Height="470"
                            Disabled="true"
                            >
                            <TopBar>
                                <ext:Toolbar ID="Toolbar1" runat="server">
                                    <Items>
                                        <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                        <ext:Button ID="Button3" runat="server" Text="Excel" Icon="PageExcel">
                                            <Listeners>
                                                <Click Handler="submitValue(#{reportGridPanel}, #{FormatType}, 'xls');" />
                                            </Listeners>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    <ext:Column ColumnID="userName" Header="Promoter" Width="270" DataIndex="NMUSER" Sortable="true" />
                                    <ext:Column ColumnID="ListName" Header="Evento" Width="162" DataIndex="NMEVENT" Sortable="true" />
                                    <ext:Column ColumnID="eventName" Header="Total Conf." Width="75" DataIndex="CONFIRMADOS" Sortable="true" />
                                    <ext:Column ColumnID="eventBnFem" Header="Bônus Fem." Width="75" DataIndex="BNFEM" Sortable="true" />
                                    <ext:Column ColumnID="eventBnMasc" Header="Bônus Masc." Width="75" DataIndex="BNMASC" Sortable="true" />
                                    <ext:Column ColumnID="eventFrFem" Header="Free Fem." Width="75" DataIndex="FRFEM" Sortable="true" />
                                    <ext:Column ColumnID="eventFrMasc" Header="Free Masc." Width="75" DataIndex="FRMASC" Sortable="true" />
                                </Columns>
                            </ColumnModel>                    
                            <LoadMask ShowMask="true" />
                            <BottomBar>
                                <ext:PagingToolBar ID="PagingToolBar" runat="server" PageSize="30" StoreID="reportStore" />
                            </BottomBar>
                        </ext:GridPanel>
                    </Center>
                </ext:BorderLayout>
            </Body>
        </ext:Panel>
    </Body>
</ext:DesktopWindow>